package org.csmzxy.class2334;

class Person {
    private String name;    //姓名
    private String role;    //身份
    private String subject; //教学科目

    //构造方法一
    public Person(String name, String role) {
        if (name != null &&!name.isEmpty() && role != null &&!role.isEmpty()) {
            this.name = name;
            this.role = role;
        } else {
            System.err.println("姓名和身份参数不能为空");
        }
    }

    //构造方法二
    public Person(String name, String role, String subject) {
        if (name != null &&!name.isEmpty() && role != null &&!role.isEmpty() && subject != null &&!subject.isEmpty()) {
            this.name = name;
            this.role = role;
            this.subject = subject;
        } else {
            System.err.println("姓名、身份和教学科目参数不能为空");
        }
    }

    public void print() {
        System.out.print("姓名: " + name + ", 身份: " + role);
        if (subject != null) {
            System.out.println(", 教学科目: " + subject);
        } else {
            System.out.println();
        }
    }
}